//
//  UIViewController+JJAop.m
//  jiajia
//
//  Created by rujia chen on 16/5/1.
//  Copyright © 2016年 sunrisin. All rights reserved.
//

#import "UIViewController+JJAop.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincomplete-implementation"
@implementation UIViewController (JJAop)

+ (void)load {
    [self jj_swizzleInstanceMethod:@selector(viewWillAppear:) with:@selector(jj_viewWillAppear:)];
    [self jj_swizzleInstanceMethod:@selector(viewWillDisappear:) with:@selector(jj_viewWillDisappear:)];
    [self jj_swizzleInstanceMethod:@selector(viewDidLoad) with:@selector(jj_viewDidLoad)];
    [self jj_swizzleInstanceMethod:@selector(viewDidAppear:) with:@selector(jj_viewDidAppear:)];
    [self jj_swizzleInstanceMethod:@selector(viewDidDisappear:) with:@selector(jj_viewDidDisappear:)];
}

- (void)jj_viewDidLoad {
    [self jj_viewDidLoad];
}

- (void)jj_viewWillAppear:(BOOL)animated {
    [self jj_viewWillAppear:animated];
    NSLog(@"[%@] will appear", NSStringFromClass([self class]));
}

- (void)jj_viewWillDisappear:(BOOL)animated {
    [self jj_viewWillAppear:animated];
    NSLog(@"[%@] will disappear", NSStringFromClass([self class]));
}

- (void)jj_viewDidAppear:(BOOL)animated {
    [self jj_viewDidAppear:animated];
    if ([self respondsToSelector:@selector(jj_addNotificationObserver:)]) {
        [self jj_addNotificationObserver:[NSNotificationCenter defaultCenter]];
    }
}

- (void)jj_viewDidDisappear:(BOOL)animated {
    [self jj_viewDidDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
#pragma clang diagnostic pop